Hi folks,
please find attached an implementation for updatable views. Included are
support
for pg_dump and information_schema, regression test and documentation are
missing. Also, there's currently no upgrade path for older PostgreSQL
versions and
user defined rules on views. I have some code which drops the implicit
created
rules silently if someone wants to have its own rule, but this needs some
discussion,
i think.
The patch covers the whole SQL92 functionality and doesn't create any
rules, if
a given view is considered not to be compatible with SQL92 definitions. The
supported
syntax is
CREATE VIEW foo AS .... [ WITH [ CASCADED | LOCAL ] CHECK OPTION ]
The check option is implemented as a conditional rule with a simple system
function, which
checks the given expression tree to be true or false and raises an error in
the latter case.
There's also a little change in the rewriter semantics, as i treat implicit
(view update rules
created automatically) and explicit rules (rules created by any user)
differently.
This involves some changes to the system catalog (especially
pg_rewrite and pg_proc), so be prepared to do an initdb. There are new files
in src/backend/rewrite/view_update.c and src/include/rewrite/view_update.h,
too.
Please note that the patch currently breaks some regression tests, but
these are
mostly due to duplicated rules on views and additional notice messages.
Also, i
have dropped support for updatable views which contains indexed array
fields
of tables (like SELECT foo[3], foo[2] FROM bar). These are treated
non-updatable and
someone needs his own rules here.
I hope there aren't too many open points here, so this patch could be
considered
for inclusion in 8.2.
Looking forward your opinions...
--
Thanks
Bernd